package trash;

import com.adxon.data.Attachee;

public class Storage extends Attachee{
/*	@SuppressWarnings("rawtypes")
	protected static Map<Integer,Class> mp;

	public static Post create(HttpServletRequest req,ServletContext context)
			throws EntityNotFoundException,InstantiationException,
			IllegalAccessException{
		messages(context);
		Uri i=new Uri();
		String p=i.parseUri(req);
		Entity e=entity("i",p);
		int k=(int)(long)e.getProperty("kn");
		@SuppressWarnings("unchecked")
		Class<Post> c=mp.get(k);
		if(c==null)
			c=Post.class;
		Post o=c.newInstance();
		o.setKey(p);
		o.typ=i.getType();
		try{
			o.update();
		}catch(Message x){
			x.printStackTrace();
		}
		return o;
	}
	private static void messages(ServletContext context){
		if(mp==null){
			try{
				register(12,Picture.class);
				String s=context.getInitParameter("extra-messages");
				StringTokenizer t=new StringTokenizer(s,",");
				while(t.hasMoreTokens())
					Class.forName(t.nextToken()).newInstance();
			}catch(InstantiationException | IllegalAccessException
					| ClassNotFoundException e){
				e.printStackTrace();
			}
		}
	}
	@SuppressWarnings("rawtypes")
	protected static void register(Integer kind,Class kindClass){
		if(mp==null){
			mp=new TreeMap<Integer,Class>();
			mp.put(1,Individual.class);
		}
		mp.put(kind,kindClass);
	}
	public static PreparedQuery query(Post template,int count){
		Filter f=null;
		if(template.kn>-1)
			f=new FilterPredicate("kn",FilterOperator.EQUAL,template.kn);
		if(template.ph!=0){
			f=f==null?new FilterPredicate("ph",FilterOperator.EQUAL,template.ph):
				CompositeFilterOperator.and(f,
					new FilterPredicate("ph",FilterOperator.EQUAL,template.ph));
		}
		Query q=new Query("i");
		if(f!=null)
			q.setFilter(f);
		q.addSort("tc",SortDirection.DESCENDING);
		return DatastoreServiceFactory.getDatastoreService().prepare(q);
	}*/
}